*Replication code for Appendix 2 figures in 
*"Explaining Public Demands for Border Miltiarization"

version 18.0
clear all
estimates clear

*Set command directory to location where replication files are saved.
*cd

use "surveypretest.dta", clear
********************************************************************************
*RENAME VARIABLES
********************************************************************************
*Rename variables for agencies' military affiliations from grid format
rename milaffiliation_1 locallaw
	tab locallaw
rename milaffiliation_2 cbp
	tab cbp
rename milaffiliation_3 natguard
	tab natguard
rename milaffiliation_4 army
	tab army
rename milaffiliation_5 coastguard
	tab coastguard
rename milaffiliation_6 navy
	tab navy

*Rename variables for militarized strategies from grid format
rename militarized_1 coordinate_mil
	tab coordinate_mil
rename militarized_2 blockborder_mil
	tab blockborder_mil
rename militarized_3 blocksmart_mil
	tab blocksmart_mil
rename militarized_4 stopmove_mil
	tab stopmove_mil
rename militarized_5 patrol_mil
	tab patrol_mil
rename militarized_6 stopdeter_mil
	tab stopdeter_mil
rename militarized_7 rootcause_mil
	tab rootcause_mil

********************************************************************************
*CREATE FIGURE A1: PUBLIC PERCEPTIONS OF AGENCIES BY MILITARY AFFILIATION
********************************************************************************
*Descriptive statistics for "How closely is each agency affiliated with the US military?"
sum locallaw cbp natguard army coastguard navy

*Figure of affiliation means
mean locallaw
	est store locallaw
mean cbp 
	est store customsandborder
mean natguard 
	est store nationalguard
mean army 
	est store army
mean coastguard 
	est store coastguard
mean navy
	est store navy

	coefplot locallaw customsandborder nationalguard army coastguard navy, /// 
		vertical ciopts(recast(rcap)) scheme(s1mono) /// 
		title("Military Affiliation Means") /// 
		xtitle("Agency") ytitle("Level of Affiliation") /// 
		xlabel(none)
	graph export "affiliations.pdf", as(pdf) replace

********************************************************************************
*CREATE FIGURE A2: PUBLIC PERCEPTIONS OF STRATEGIES BY DEGREE OF MILITARIZATION
********************************************************************************
*Descriptive statistics for "How militarized are each of the following policies?"
sum coordinate_mil blockborder_mil blocksmart_mil stopmove_mil /// 
	patrol_mil stopdeter_mil rootcause_mil

*Figure of militarizatio means	
mean coordinate_mil 
	est store coordinate
mean blockborder_mil 
	est store blockborderlegal
mean blocksmart_mil 
	est store smarttech
mean stopmove_mil
	est store stopmove
mean patrol_mil 
	est store patrolwall
mean stopdeter_mil 
	est store stopwitharmed
mean rootcause_mil
	est store rootcause
	
	coefplot coordinate blockborderlegal smarttech stopmove patrolwall /// 
		stopwitharmed rootcause, vertical ciopts(recast(rcap)) scheme(s1mono) /// 
		title("Means of Perceived Militarization") /// 
		xtitle("Policy") ytitle("Level of Militarization") /// 
		xlabel(none)
	graph export "militarizatonmeans.pdf", as(pdf) replace

